package gemini.basic.model;

// default package
// Generated Nov 23, 2010 4:23:01 PM by Hibernate Tools 3.4.0.Beta1

import static javax.persistence.GenerationType.IDENTITY;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 * Cart generated by hbm2java
 */
@Entity
@Table(name = "g_cart", catalog = "gemini")
public class Cart extends AbstractDomain implements java.io.Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private Integer id;
	private Integer version;
	private Address addressByShippingAddress;
	private Distributor distributor;
	private Address addressByBillingAddress;
	private Payment payment;
	private Date processingDate;
	private List<Order> orders = new ArrayList<Order>(0);
	private List<CartStatus> cartStatuses = new ArrayList<CartStatus>(0);

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Version
	@Column(name = "version")
	public Integer getVersion() {
		return this.version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "shipping_address_id")
	public Address getAddressByShippingAddress() {
		return this.addressByShippingAddress;
	}

	public void setAddressByShippingAddress(
			Address addressByShippingAddress) {
		this.addressByShippingAddress = addressByShippingAddress;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "distributor_id", nullable = false)
	public Distributor getDistributor() {
		return this.distributor;
	}

	public void setDistributor(Distributor distributor) {
		this.distributor = distributor;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "billing_address_id")
	public Address getAddressByBillingAddress() {
		return this.addressByBillingAddress;
	}

	public void setAddressByBillingAddress(
			Address addressByBillingAddress) {
		this.addressByBillingAddress = addressByBillingAddress;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "processing_date", nullable = false, length = 10)
	public Date getProcessingDate() {
		return this.processingDate;
	}

	public void setProcessingDate(Date processingDate) {
		this.processingDate = processingDate;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "cart")
	public List<Order> getOrders() {
		return this.orders;
	}

	public void setOrders(List<Order> orders) {
		this.orders = orders;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "cart")
	@Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE})
	public List<CartStatus> getCartStatuses() {
		return this.cartStatuses;
	}

	public void setCartStatuses(List<CartStatus> cartStatuses) {
		this.cartStatuses = cartStatuses;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "payment_id")
	public Payment getPayment() {
		return this.payment;
	}

	public void setPayment(Payment payment) {
		this.payment = payment;
	}
}
